package com.wei.web.middleware.httpfilter.registrar.filter;

import com.wei.web.middleware.httpfilter.registrar.model.FilterConfigDTO;
import com.wei.web.middleware.httpfilter.registrar.model.RegisterContext;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.web.filter.GenericFilterBean;

public class CustomFilterFactoryBeanRegistrar extends AbstractFilterRegistrar {

    public static final String TYPE = "customFilterFactory";

    @Override
    public String getType() {
        return TYPE;
    }

    @Override
    public void registrar(FilterConfigDTO filterConfigDTO, BeanDefinitionRegistry registry, RegisterContext registerContext) {
        String filterName = getFilterNameWithDefault(filterConfigDTO, registerContext);
        doRegisterWithFactoryBeanName(filterConfigDTO, filterName,
                registerContext.getFilterOrder(),
                filterConfigDTO.getUrlPatterns(),
                filterConfigDTO.getFactoryBeanName(),
                registry);

    }
}
